package com.syxbbs.forum.config;

import com.syxbbs.forum.Interceptor.LoginInterceptor;
import jakarta.annotation.Resource;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {
    @Resource
    private LoginInterceptor loginInterceptor;
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //添加用户拦截器
        registry.addInterceptor(loginInterceptor)
                //拦截哪些接口，拦截所有接口，除了sign-in，up等以及前端。
                .addPathPatterns("/**")
                .excludePathPatterns("/user/login")
                .excludePathPatterns("/dist/**")
                .excludePathPatterns("/image/**")
                .excludePathPatterns("/js/**")
                .excludePathPatterns("/pic/**")
                .excludePathPatterns("/favicon.ico")
                //.excludePathPatterns("/**/*.html")
                .excludePathPatterns("/sign-in.html")
                .excludePathPatterns("/sign-up.html")
                .excludePathPatterns("/user/login")
                .excludePathPatterns("/user/register");
                //.excludePathPatterns("/**/*.html")

    }
}